'''
Created on May 9, 2010

@author: roni
'''
from projectConstants import ProjectConstants

class FlowDetails(object):
    '''
    Class for holding details of a traffic flow
    '''
    def __init__(self,flow_id, source,target,in_file = None):
        '''
        Constructor
        '''
        self.flow_id = flow_id
        self.source = source
        self.target = target
        self.path = []
        if in_file is not None:
            self.load(in_file)
    
    def setDelay(self,delay):
        self.delay = delay
    def setPacketCount(self,packet_count):
        self.packet_count = packet_count

    def __str__(self):
        return "%s: %s->%s %f1.2 (%d)" % (self.flow_id,self.source,self.target,self.delay,self.packet_count)
            
    def __eq__(self,obj):
        if self.flow_id!=obj.flow_id:
            return False
        if self.source!=obj.source:
            return False
        if self.target!=obj.target:
            return False
        if abs(self.delay-obj.delay)>ProjectConstants.DELAY_ACCURACY:
            return False
        if self.packet_count!=obj.packet_count:
            return False     
        return True   
        
        
                                